package com.fit.user.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fit.user.dao.CaseMsgDAO;

public class AddRemark extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Constructor of the object.
	 */
	public AddRemark() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost( request,  response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String remark = request.getParameter("remark");
		String caseID = request.getParameter("caseID");
		CaseMsgDAO caseMsgDAO = new CaseMsgDAO();
		boolean addRemark = caseMsgDAO.addRemark(caseID, remark);
		if(addRemark)
		{
			response.sendRedirect(request.getContextPath() + "/police/select_case.jsp");
			
		}
		System.out.println(remark+caseID);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
